package eleven;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zzb
 * @since 2021-01-13
 */

//FlyweightFactory
public class FlyweightFactory {
  private static Map flyweights = new HashMap();

  public static Flyweight getFlyweight(String key) {
    if (flyweights.get(key) == null) {
      flyweights.put(key, new FlyweightImpl());
    }
    return (Flyweight) flyweights.get(key);
  }

  public static int getSize() {
    return flyweights.size();
  }
}
